//
//  VCOfOfficial.m
//  ProjectA_ManualGuest
//
//  Created by dingcong on 16/7/5.
//  Copyright © 2016年 丁聪. All rights reserved.
//

#import "VCOfOfficial.h"
#import "NetWorkingHandle.h"
#import "CellOfVidioImg.h"
#import <WebKit/WebKit.h>
#import "VcOfWebView.h"
@interface VCOfOfficial ()

@property(nonatomic, retain)NSMutableArray *mArrOfData;
@end

@implementation VCOfOfficial

- (void)dealloc{
    
    [_mArrOfData release];
    [super dealloc];
    
    
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    [self GetData];
    
    [self.tableView registerClass:[CellOfVidioImg class] forCellReuseIdentifier:@"pool1"];
}


- (void)GetData{
    
    NSString *url = @"http://m.shougongke.com/index.php?c=Shiji&a=topicListS&tag_id=62&vid=18&channel=shougongke_004&app_token=866068026911107&app_version=119_5.8";
    NetWorkingHandle *net = [[NetWorkingHandle alloc]init];
    self.mArrOfData = [NSMutableArray array];
    [net netWorkingHandlerGetWithURL:url completion:^(id result, NSData *data, NSURLResponse *response, NSError *error) {
        
        NSLog(@"shujv:%@", result);
        NSArray *arr = [result objectForKey:@"data"];
        for (NSDictionary *dic in arr)
        {
            HandPanitedModel *model = [[HandPanitedModel alloc]init];
            [model setValuesForKeysWithDictionary:dic];
            
            [self.mArrOfData addObject:model];
            
            
            [model release];
        }
        
        
        
        
        [self.tableView reloadData];
        
    }];
    
    
    
    
    
    
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    return self.mArrOfData.count;
    
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 180;
    
    
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    CellOfVidioImg *cell = [tableView dequeueReusableCellWithIdentifier:@"pool1"];
    
    cell.handModel = self.mArrOfData[indexPath.row];
    
    return cell;
    
    
    
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    HandPanitedModel *model = self.mArrOfData[indexPath.row];
    
    WKWebView *webView = [[WKWebView alloc]initWithFrame:self.view.frame];
    
    NSString *url = model.mob_h5_url;
    
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
    
    
    VcOfWebView *vc = [[VcOfWebView alloc]init];
    
    webView.frame = CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT);
    [vc.view addSubview:webView];
    
    [self.navigationController pushViewController:vc animated:YES];
    
    [vc release];
    [webView release];
    
    
    
    
    
    
    
    
}

@end
